package com.zbkc.main;

import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

public class MyAdapter extends BaseAdapter {

	private LayoutInflater inflater = null;
	private boolean isEdit;
	private ArrayList<HashMap<String, String>> list;

	public MyAdapter(Context paramContext,
			ArrayList<HashMap<String, String>> paramArrayList,
			boolean paramBoolean) {
		this.list = paramArrayList;
		this.isEdit = paramBoolean;
		this.inflater = LayoutInflater.from(paramContext);
	}

	public int getCount() {
		return this.list.size();
	}

	public Object getItem(int paramInt) {
		return this.list.get(paramInt);
	}

	public long getItemId(int paramInt) {
		return paramInt;
	}

	public View getView(int paramInt, View paramView, ViewGroup paramViewGroup) {
		ViewHolder localViewHolder;
		if (paramView == null) {
			localViewHolder = new ViewHolder();
			paramView = this.inflater.inflate(2130903061, null);
			localViewHolder.tvTitle = ((TextView) paramView
					.findViewById(2131296293));
			localViewHolder.checkBox = ((CheckBox) paramView
					.findViewById(2131296266));
			localViewHolder.ivArrow = ((ImageView) paramView
					.findViewById(2131296295));
			paramView.setTag(localViewHolder);
			if (!isEdit) {
				localViewHolder.checkBox.setVisibility(View.GONE);
				localViewHolder.ivArrow.setVisibility(View.VISIBLE);
			}

		} else {
			localViewHolder = (ViewHolder) paramView.getTag();
		}

		localViewHolder.tvTitle.setText(((String) ((HashMap) this.list
				.get(paramInt)).get("filename")).toString());
		localViewHolder.checkBox.setChecked(((String) ((HashMap) this.list
				.get(paramInt)).get("flag")).equals("true"));
		localViewHolder.checkBox.setVisibility(View.VISIBLE);
		localViewHolder.ivArrow.setVisibility(View.GONE);

		return paramView;

	}

	final class ViewHolder {
		CheckBox checkBox;
		ImageView ivArrow;
		TextView tvTitle;
	}

}
